package com.itzzy.dice.config;

import com.itzzy.dice.bean.entity.RoomInfo;
import xyz.noark.core.annotation.Autowired;
import xyz.noark.core.annotation.Component;
import xyz.noark.core.network.AbstractNetworkListener;
import xyz.noark.core.network.Session;
import xyz.noark.core.network.SessionAttrKey;

@Component
public class NetworkListenerConfig extends AbstractNetworkListener {

    @Autowired
    private CaffeineUtils caffeineUtils;

    @Override
    public void channelActive(Session session) {
    }

    @Override
    public void channelInactive(Session session) {
        Object roomIdObj = session.attr(SessionAttrKey.valueOf("roomId")).get();
        if (roomIdObj == null){
            return;
        }
        // 获取房间号
        String roomId = roomIdObj.toString();

        // 根据房间号获取信息
        RoomInfo roomInfo = caffeineUtils.getObjCacheByKey(roomId);
    }

}
